package com.maomao.aop.bean;

import com.maomao.aop.proxy.PersonProxyFactory;
import com.maomao.aop.service.Speakable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by admin on 2018/3/21.
 */
@Configuration
public class CommandBean {

    @Autowired
    private Speakable personSpring;
    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx){
        return args ->{
            System.out.println("****spring aop*****");
            personSpring.sayHi();
            personSpring.sayBye();
            System.out.println("****jdk dynamic proxy ****");
            Speakable jdkProxy= PersonProxyFactory.newJdkProxy();
            jdkProxy.sayHi();
            jdkProxy.sayBye();
//            System.exit(0);
        };
    }
}
